package pers.cmc.mysql.chain;

import org.omg.CORBA.Object;
import pers.cmc.mysql.core.Reflex;
import pers.cmc.mysql.model.Extension;
import pers.cmc.mysql.model.Select;
import pers.cmc.mysql.util.StringUtils;

import java.util.Map;

/**
 * 负责链式调用
 * @author EDY
 */
public class Table {
    Select select;

    /** 调用table 创建一个Selete对象 */
    public Table(String table) {
        this.select = new Select();
        this.select.addTable(table);
    }

    public Table where(String field, String jud) throws IllegalAccessException {
        return where(field,"=",jud);
    }

    public Table where(String field, String jud, java.lang.String term) throws IllegalAccessException {
        return where(field, jud, term, new Extension());
    }

    public Table where(String field, String jud, java.lang.String term, Extension many) throws IllegalAccessException {
        java.lang.String sql = "";
        sql = many.getLeft() + field + jud + term + many.getRight();
        select.putStructure("where", sql);
        return this;
    }

    public Table where(String field, String jud, java.lang.String[] term, Extension many) throws IllegalAccessException {
        java.lang.StringBuilder sql = new StringBuilder();
        sql.append(many.getLeft());
        for (java.lang.String e : term){
            sql.append(field).append(jud).append(e);
        }
        sql.append(many.getRight());
        select.putStructure("where", sql.toString());
        return this;
    }


    /** orWhere方法 */
    public Table orWhere(){

        return this;
    }
    /** on方法 */
    public Table on(){

        return this;
    }

    /** aon */
    public Table aon(){

        return this;
    }

    /** ron */
    public Table ron(){

        return this;
    }

    /** onWhere */
    public Table onWhere(){

        return this;
    }

    /** ronWhere */
    public Table ronWhere(){

        return this;
    }

    /** join */
    public Table join(){

        return this;
    }

    /** join_left */
    public Table joinLeft(){

        return this;
    }

    /** join_right */
    public Table joinRight(){

        return this;
    }

    /** offset */
    public Table offset(){

        return this;
    }

    /** limit */
    public Table limit(){

        return this;
    }

    /** orderBy */
    public Table orderBy(){

        return this;
    }

    /** update */
    public Table update(){

        return this;
    }

    /** increment */
    public Table increment(){

        return this;
    }

    /** decrement */
    public Table decrement(){

        return this;
    }

    /** insert */
    public Table insert(){

        return this;
    }

    /** insertId */
    public Table insertId(){

        return this;
    }

    /** value */
    public Table value(){

        return this;
    }

    /** noGet */
    public Table noGet(){

        return this;
    }

    /** noFirst */
    public Table noFirst(){

        return this;
    }

    /** first */
    public Table first(){

        return this;
    }

    /** delete */
    public Table delete(){

        return this;
    }

    /** count */
    public Table count(){

        return this;
    }

    /** paging */
    public Table paging(){

        return this;
    }


    /** toSql */
    public Table toSql(){

        return this;
    }


}
